import { interForm, interTable } from "@b/model/base/type";
import { List } from "../model/base/list";
import { ListSearch } from "@b/model/base/list_search";
import { h } from "vue";
import { ElDatePicker, ElOption, ElSelect } from "element-plus";
import { EQUIPMENT } from "@b/model/enum";

export class ReferralSearch extends ListSearch {
    constructor(type: 1 | 2 = 1) {
        super()
        // examAndAssay  检验检查
        // outpatient 上转门诊
        // inpatient 上转住院
        // operation 上转日间手术管理中心
        // rehabilitation 下转康复
        let types: { name: string, value: string }[] = [];
        if (type === 1) {
            types = [
                { name: '上转检查检验', value: 'examAndAssay' },
                { name: '上转门诊', value: 'outpatient' },
                { name: '上转住院', value: 'inpatient' },
                { name: '上转日间手术', value: 'operation' },
                { name: '下转康复', value: 'rehabilitation' }
            ]
        } else {
            EQUIPMENT.forEach((value, key) => {
                types.push({ name: value, value: key })
            })
        }
        this.labels = new Map<string, interForm>([
            ['Category', {
                prop: 'Category',
                label: '类别',
                vform: (prop: string, data: any, value: string) => h(ElSelect, {
                    clearable: true, teleported: false,
                    placeholder: '请选择类别', modelValue: value, "onUpdate:modelValue": (inputValue: string) => {
                        data[prop] = inputValue
                    }
                }, { default: () => types.map((item: any) => h(ElOption, { label: item.name, value: item.value, key: item.value })) })
            }],
            ['WorkStation', {
                prop: 'WorkStation',
                label: '转诊机构'
            }],
            ['Time', {
                prop: 'Time',
                label: '时间',
                vform: (prop, data, value) => h(ElDatePicker, {
                    teleported: false,
                    startPlaceholder: '开始时间', endPlaceholder: '结束时间', disabledDate: (date: any) =>
                        date > new Date() || date < new Date('2023-8-1'),
                    modelValue: value, type: 'daterange', "onUpdate:modelValue": (inputValue: string) => {
                        data[prop] = inputValue
                    }
                })
            }]
        ])
    }
}
export class Referral extends List {
    right: any;
    constructor() {
        super()
        this.url.getlist = '/v1/bigscreen/GetTransferTreatOrders'
        this.right = {
            examAssem: [{ name: '', value: '' }, { name: '', value: '' }],
            transferTreatInfo: [{ name: '', value: '' }, { name: '', value: '' }],
            rjssAndRecovery: [{ name: '', value: '' }, { name: '', value: '' }]
        }
        this.labels = new Map<string, interTable>([['patientName', {
            prop: 'patientName',
            label: '患者姓名', width: 100
        }], ['diagnosisName', {
            prop: 'diagnosisName',
            label: '初步诊断'
        }], ['upTreatTypeName', {
            prop: 'upTreatTypeName',
            label: '转诊类别', width: 120,
            formatter: (p, d, value) => EQUIPMENT.get(value) || '上转检查检验'
        }], ['transferOrgName', {
            prop: 'transferOrgName',
            label: '转诊机构'
        }], ['tranferDoctorName', {
            prop: 'tranferDoctorName',
            label: '转诊医生', width: 100
        }], ['confirmTime', {
            prop: 'confirmTime',
            label: '接诊时间'
        }], ['receiveOrgName', {
            prop: 'receiveOrgName',
            label: '接诊机构',
            formatter: (p, d, value) => value + '医共办'
        }], ['receiveDoctorName', {
            prop: 'receiveDoctorName',
            label: '接诊医生'
        }]])
    }
    async getRightData() {
        this.right = await this.request('/v1/bigscreen/GetAcumulate', { method: 'GET' })
    }
}
export class Referral1 extends List {
    constructor() {
        super()
        this.url.getlist = '/v1/bigscreen/GetTransferTreatOrders'
        this.labels = new Map<string, interTable>([['patientName', {
            prop: 'patientName',
            label: '患者姓名', width: 100
        }], ['diagnosisName', {
            prop: 'diagnosisName',
            label: '初步诊断'
        }], ['examName', {
            prop: 'examName',
            label: '检查项目', width: 120,
            formatter: (p, d, value) => EQUIPMENT.get(value) || '其他'
        }], ['transferOrgName', {
            prop: 'transferOrgName',
            label: '转诊机构'
        }], ['tranferDoctorName', {
            prop: 'tranferDoctorName',
            label: '转诊医生', width: 100
        }], ['confirmTime', {
            prop: 'confirmTime',
            label: '接诊时间'
        }], ['receiveOrgName', {
            prop: 'receiveOrgName',
            label: '接诊机构',
            formatter: (p, d, value) => value + '医共办'
        }], ['receiveDoctorName', {
            prop: 'receiveDoctorName',
            label: '接诊医生'
        }]])
    }
}
export class Referral2 extends List {
    constructor() {
        super()
        this.url.getlist = '/v1/bigscreen/GetTransferTreatOrders'
        this.labels = new Map<string, interTable>([['patientName', {
            prop: 'patientName',
            label: '患者姓名', width: 100
        }], ['diagnosisName', {
            prop: 'diagnosisName',
            label: '初步诊断'
        }], ['upTreatTypeName', {
            prop: 'upTreatTypeName',
            label: '转诊类别', width: 120,
            formatter: (p, d, value) => EQUIPMENT.get(value) || '上转检查检验'
        }], ['transferOrgName', {
            prop: 'transferOrgName',
            label: '转诊机构'
        }], ['tranferDoctorName', {
            prop: 'tranferDoctorName',
            label: '转诊医生', width: 100
        }], ['confirmTime', {
            prop: 'confirmTime',
            label: '接诊时间'
        }], ['receiveOrgName', {
            prop: 'receiveOrgName',
            label: '接诊机构',
            formatter: (p, d, value) => value + '医共办'
        }], ['receiveDoctorName', {
            prop: 'receiveDoctorName',
            label: '接诊医生'
        }]])
    }
}
export class Referral3 extends List {
    constructor() {
        super()
        this.url.getlist = '/v1/bigscreen/GetTransferTreatOrders'
        this.labels = new Map<string, interTable>([['patientName', {
            prop: 'patientName',
            label: '患者姓名', width: 100
        }], ['diagnosisName', {
            prop: 'diagnosisName',
            label: '初步诊断'
        }], ['upTreatTypeName', {
            prop: 'upTreatTypeName',
            label: '转诊类别', width: 120,
            formatter: (p, d, value) => EQUIPMENT.get(value) || '上转检查检验'
        }], ['transferOrgName', {
            prop: 'transferOrgName',
            label: '转诊机构'
        }], ['tranferDoctorName', {
            prop: 'tranferDoctorName',
            label: '转诊医生', width: 100
        }], ['confirmTime', {
            prop: 'confirmTime',
            label: '接诊时间'
        }], ['receiveOrgName', {
            prop: 'receiveOrgName',
            label: '接诊机构',
            formatter: (p, d, value) => value + '医共办'
        }], ['receiveDoctorName', {
            prop: 'receiveDoctorName',
            label: '接诊医生'
        }]])
    }
}
export class Equipment extends List {
    chartsData: any;
    constructor() {
        super()
        this.limit = 6
        this.url.getlist = '/v1/bigscreen/GetTransferTreatOrders'
        this.labels = new Map<string, interTable>([['patientName', {
            prop: 'patientName',
            label: '患者姓名', width: 100
        }], ['diagnosisName', {
            prop: 'diagnosisName',
            label: '初步诊断'
        }], ['examName', {
            prop: 'examName',
            label: '检查项目', width: 120,
            formatter: (p, d, value) => EQUIPMENT.get(value) || '其他'
        }], ['transferOrgName', {
            prop: 'transferOrgName',
            label: '转诊机构'
        }], ['tranferDoctorName', {
            prop: 'tranferDoctorName',
            label: '转诊医生', width: 100
        }], ['confirmTime', {
            prop: 'confirmTime',
            label: '接诊时间'
        }], ['receiveOrgName', {
            prop: 'receiveOrgName',
            label: '接诊机构',
            formatter: (p, d, value) => value + '医共办'
        }], ['receiveDoctorName', {
            prop: 'receiveDoctorName',
            label: '接诊医生'
        }]])
    }
    async befaultGetList(options: any) {
        this.chartsData = await this.request('/v1/bigscreen/GetSharedDeviceGroupByDate', options)
    }
}